<template>
	<view>
		<view class="notice-item" v-for="item in info">
			<view class="content">
				<text class="title">{{item.title}}</text>
				<jyf-parser class="introduce" :html="item.content" ref="article"></jyf-parser>
				<view class="time">{{item.createtime}}</view>
			</view>
		</view>
		<view class="notic-msg" v-if="noticMsg">
			-- 没有更多了 --
		</view>
	</view>
</template>

<script>
	import jyfParser from "@/components/jyf-parser/jyf-parser";
	export default {
		data() {
			return {
				page: 1,
				cateid: '',
				info: [],
				noticMsg: 0,
			}
		},
		components: {
			jyfParser
		},
		onLoad(options) {
			var that = this;
			if(options.title){
				uni.setNavigationBarTitle({
					title:options.title
				})
			}
			that.cateid = options.cateid;
			uni.showLoading({
				title: '加载中'
			})
			that.$axios('index/msglist', 'POST', 'salemsg', {
				page: that.page,
				cateid: that.cateid
			}).then(res => {
				uni.hideLoading();
				if (res.data.code == 200) {
					that.info = res.data.data.list;
				} else {
					that.$api.msg(res.data.data)
				}
			})
		},
		onReachBottom() {
			var that = this;
			that.page = that.page + 1
			uni.showLoading({
				title: '加载中'
			})
			that.$axios('index/msglist', "POST", 'salemsg', {
				page: that.page,
				cateid: that.cateid
			}).then(res => {
				uni.hideLoading();
				if (res.data.code == 200) {
					if (res.data.data.list.length <= 0) {
						that.noticMsg = 1;
					}
					that.info = that.info.concat(res.data.data.list)
				} else {
					that.$api.msg(res.data.data)
				}
			})
		},
		methods: {
			navto(e) {
				var a = e.split('/')[0];
				if (a == 'http:') {
					location.href = e;
				} else {
					uni.navigateTo({
						url: e
					})
				}
			}
		}
	}
</script>

<style lang='scss'>
	page {
		background-color: #f7f7f7;
	}

	.notice-item {
		margin-top: 20upx;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.content {
		width: 710upx;
		padding: 0 24upx;
		background-color: #fff;
		border-radius: 4upx;
	}

	.title {
		display: flex;
		align-items: center;
		line-height: 70upx;
		padding-top: 20upx;
		font-size: 32upx;
		color: #303133;
	}

	.introduce {
		display: inline-block;
		padding-bottom: 16upx;
		font-size: 28upx;
		color: #606266;
		line-height: 38upx;
	}

	.time {
		font-size: 28upx;
		text-align: right;
		color: #909399;
		padding-bottom: 20upx;
	}

	.notic-msg {
		color: #4399fc;
		line-height: 80upx;
		height: 80upx;
		font-size: 30upx;
		text-align: center;
	}
</style>
